val studentsDF = spark.read.format("jdbc").option("url", "jdbc:mysql://localhost:3306/sparksql_practice").option("dbtable", "students").option("user", "root").option("password", "root").option("driver", "com.mysql.jdbc.Driver").option("useSSL", "false").load()
val filteredStudentsDF = studentsDF.filter(col("age") <= 30)
filteredStudentsDF.write
.format("jdbc")
.option("url", "jdbc:mysql://localhost:3306/sparksql_practice")
.option("dbtable", "students")
.option("user", "root")
.option("password", "root")
.option("driver", "com.mysql.jdbc.Driver")
.option("useSSL", "false")
.mode("overwrite")
.save()



val specificStudentId = 1
val studentsWithoutSpecificIdDF = studentsDF.filter(col("student_id") !== specificStudentId)
studentsWithoutSpecificIdDF.write
.format("jdbc")
.option("url", "jdbc:mysql://localhost:3306/sparksql_practice")
.option("dbtable", "students")
.option("user", "root")
.option("password", "root")
.option("driver", "com.mysql.jdbc.Driver")
.option("useSSL", "false")
.mode("overwrite")
.save()